package com.atguigu.springboot.listener;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * @author : leimingchao
 * @date Date : 2021年10月17日 17:25
 */
public class HelloSpringApplicationRunListener implements SpringApplicationRunListener {

    public HelloSpringApplicationRunListener(SpringApplication application, String[] args) {
    }
    @Override
    public void starting() {
        System.out.println("SpringApplicationRunListener.....starting....");
    }

    @Override
    public void environmentPrepared(ConfigurableEnvironment environment) {
        Object object = environment.getSystemProperties().get("os.name");
        System.out.println("SpringApplicationRunListener.....environmentPrepared...." + object);
    }

    @Override
    public void contextPrepared(ConfigurableApplicationContext context) {
        System.out.println("SpringApplicationRunListener.....contextPrepared...." + context);
    }

    @Override
    public void contextLoaded(ConfigurableApplicationContext context) {
        System.out.println("SpringApplicationRunListener.....contextLoaded...." + context);
    }

    @Override
    public void finished(ConfigurableApplicationContext context, Throwable exception) {
        System.out.println("SpringApplicationRunListener.....finished...." + context);
    }
}
